/**
 * 这个脚本用来在HTML页面中查找曲线的数据。大致的情况是，百度将数据保存在一个svg元素内，通过一系列的判断和查找寻找
 * 所需的数据并输出到控制台。 
 */

/* 查找页面中出现的所有可能的svg标签 */
let svgTags = document.getElementsByTagName('svg');
let noneValuePreserveAspectRatioSVGs = [];
for (let svg of svgTags) {
    if ('none' === svg.getAttribute('preserveAspectRatio')) {
        noneValuePreserveAspectRatioSVGs.push(svg);
    }
}

/* 判断指定的svg是否有且只有1个，否则，提示错误 */
if (1 !== noneValuePreserveAspectRatioSVGs.length) {
    console.error('找不到SVG或者页面结构已经发生变更，寻找数据失败。');
} else {
    let svgTarget = noneValuePreserveAspectRatioSVGs[0];
    /* 只需要第一个polyline元素 */
    let dataPolyline = null;
    for (let dataElement of svgTarget.children) {
        if (dataElement.nodeName.toLowerCase() === 'polyline') {
            dataPolyline = dataElement;
            break;
        }
    }
    if (null === dataPolyline) {
        console.error('找不到所需要的数据，页面结构可能发生了改变。');
    } else {
        let dataString = dataPolyline.getAttribute('points');
        if (null === dataString) {
            console.error('找不到数据所在的属性，数据查找失败。');
        } else {
            console.log("找到了，请复制并保存，后期处理：\n" + dataString);
        }
    }
}

/*

找到了，请复制并保存，后期处理：
1.5,71.44186046511626 6.461538461538462,71.44186046511626 12.923076923076923,65.86046511627907 19.384615384615387,77.02325581395345 25.846153846153847,82.60465116279069 32.30769230769231,82.60465116279069 38.769230769230774,65.86046511627907 45.23076923076923,71.44186046511626 51.69230769230769,77.02325581395345 58.15384615384615,77.02325581395345 64.61538461538461,82.60465116279069 71.07692307692308,77.02325581395345 77.53846153846155,65.86046511627907 84,54.697674418604656 90.46153846153847,60.27906976744185 96.92307692307692,71.44186046511626 103.38461538461539,71.44186046511626 109.84615384615385,65.86046511627907 116.3076923076923,54.697674418604656 122.76923076923077,60.27906976744185 129.23076923076923,60.27906976744185 135.6923076923077,65.86046511627907 142.15384615384616,65.86046511627907 148.6153846153846,60.27906976744185 155.0769230769231,54.697674418604656 161.53846153846155,4.465116279069775 168,21.20930232558139 174.46153846153845,15.6279069767442 180.92307692307693,21.20930232558139 187.3846153846154,32.37209302325581 193.84615384615384,32.37209302325581 200.30769230769232,37.95348837209305 206.76923076923077,49.11627906976742 213.23076923076923,54.697674418604656 219.6923076923077,60.27906976744185 226.15384615384616,60.27906976744185 232.6153846153846,49.11627906976742 239.0769230769231,43.53488372093023 245.53846153846155,54.697674418604656 252,65.86046511627907 258.46153846153845,71.44186046511626 264.9230769230769,71.44186046511626 271.3846153846154,65.86046511627907 277.84615384615387,65.86046511627907 284.3076923076923,77.02325581395345 290.7692307692308,77.02325581395345 297.2307692307692,71.44186046511626 303.6923076923077,65.86046511627907 310.1538461538462,54.697674418604656 316.61538461538464,43.53488372093023 323.0769230769231,26.790697674418624 329.53846153846155,10.046511627907009 336,21.20930232558139 342.46153846153845,43.53488372093023 348.9230769230769,49.11627906976742 355.3846153846154,54.697674418604656 361.84615384615387,43.53488372093023 368.3076923076923,43.53488372093023 374.7692307692308,32.37209302325581 381.2307692307692,43.53488372093023 387.6923076923077,43.53488372093023 394.1538461538462,37.95348837209305 400.61538461538464,54.697674418604656 407.0769230769231,60.27906976744185 413.53846153846155,60.27906976744185 420,60.27906976744185

*/
